package com.baizhi.controller;

import com.baizhi.entity.User;
import com.baizhi.service.AdminService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Tag(name="管理员管理模块",description = "管理员管理的控制器")
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private AdminService adminService;

    @PostMapping("/add")
    public ResponseEntity<String> addAdmin(@RequestBody User user){
        Boolean aBoolean = adminService.addAdmin(user);
        if(aBoolean){
            return ResponseEntity.ok("管理员添加成功");
        }else{
            return ResponseEntity.ofNullable("管理员添加失败");
        }
    }
}
